package org.kabeja.parser.entities;

import org.kabeja.dxf.DXFDocument;
import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.dxf.entity.DXFLine;
import org.kabeja.dxf.helpers.Point;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:29
 */
public class DXFLineHandler extends AbstractEntityHandler {
    public static final String ENTITY_NAME = "LINE";
    private DXFLine line;
    private DXFDocument doc;
    private String layerID = "";

    public DXFLineHandler() {
    }

    @Override
    public String getDXFEntityName() {
        return "LINE";
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 10:
                this.line.getStartPoint().setX(var2.getDoubleValue());
                break;
            case 11:
                this.line.getEndPoint().setX(var2.getDoubleValue());
                break;
            case 20:
                this.line.getStartPoint().setY(var2.getDoubleValue());
                break;
            case 21:
                this.line.getEndPoint().setY(var2.getDoubleValue());
                break;
            case 30:
                this.line.getStartPoint().setZ(var2.getDoubleValue());
                break;
            case 31:
                this.line.getEndPoint().setZ(var2.getDoubleValue());
                break;
            default:
                break;
        }

        super.parseCommonProperty(var1, var2, this.line);
    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.line);
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.line;
    }

    @Override
    public void startDXFEntity() {
        this.line = new DXFLine();
        this.line.setStartPoint(new Point());
        this.line.setEndPoint(new Point());
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public void setDXFDocument(DXFDocument var1) {
        this.doc = var1;
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }
}
